if (FIPS_EMSCRIPTEN)
    add_definitions(-DSOKOL_GLES2)
    set(slang "glsl100")
elseif (FIPS_WINDOWS)
    add_definitions(-DSOKOL_D3D11)
    set(slang "hlsl4")
elseif (FIPS_OSX)
    add_definitions(-DSOKOL_METAL)
    if (FIPS_IOS)
        set(slang "metal_ios:metal_sim")
    else()
        set(slang "metal_macos")
    endif()
else()
    add_definitions(-DSOKOL_GLCORE33)
    set(slang "glsl330")
endif()

fips_begin_lib(sokol)
    fips_vs_warning_level(3)
    if (FIPS_OSX)
        fips_files(sokol.m)
        if (FIPS_IOS)
            fips_frameworks_osx(UIKit Metal MetalKit AudioToolbox)
        else()
            fips_frameworks_osx(Cocoa QuartzCore Metal MetalKit AudioToolbox)
        endif()
    else()
        fips_files(sokol.c)
        if (FIPS_ANDROID)
            fips_libs(GLESv3 EGL OpenSLES log android)
        elseif (FIPS_LINUX)
            fips_libs(X11 Xcursor Xi GL m dl asound)
        endif()
    endif()
fips_end_lib()

fips_begin_app(v6502r windowed)
    fips_vs_warning_level(3)
    fips_files(v6502r.c v6502r.h chipvis.c pick.c gfx.c sim.c trace.c util.c asm.c)
    fips_files(segdefs.c segdefs.h nodenames.c nodenames.h)
    fips_files(ui.cc ui_asm.cc)
    sokol_shader(chipvis.glsl ${slang})
    fips_dir(res)
    fips_generate(FROM fonts.yml TYPE dump HEADER fonts.h)
    fips_generate(FROM markdown.yml TYPE dump HEADER markdown.h)
    fips_files(help_assembler.md about.md favicon.png)
    fips_deps(sokol imgui perfect6502 texteditor asmx)
fips_end_app()
